class User {
  final int userId;
  final String userName;
  final String nickName;
  final String phoneNumber;
  final int deptId;
  final String sex;
  final String? avatar;
  final String? email;

  User({
    required this.userId,
    required this.userName,
    required this.nickName,
    required this.phoneNumber,
    required this.deptId,
    required this.sex,
    this.avatar,
    this.email,
  });

  factory User.fromJson(Map<String, dynamic> json) {
    return User(
      userId: json['userId'],
      userName: json['userName'],
      nickName: json['nickName'],
      phoneNumber: json['phonenumber'] ?? '',
      deptId: json['deptId'],
      sex: json['sex'],
      avatar: json['avatar'],
      email: json['email'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'userId': userId,
      'userName': userName,
      'nickName': nickName,
      'phonenumber': phoneNumber,
      'deptId': deptId,
      'sex': sex,
      'avatar': avatar,
      'email': email,
    };
  }
}
